package com.work05;

import java.util.concurrent.ArrayBlockingQueue;

public class work05 {
    public static void main(String[] args) {
        ArrayBlockingQueue bd = new ArrayBlockingQueue(10);

        new Thread(() -> {
            while (true) {

                    try {
                        bd.put(bd);

                        System.out.println("生产存入1个单位货物，现在仓库剩余"+bd.size());
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }




        }).start();

        new Thread(()->{
            while (true){
                try {
                    bd.take();
                    System.out.println("消费取出1个单位货物，现在仓库剩余"+bd.size());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
}
